﻿
@{
    ViewBag.Title = Resources.WebStringsWeb.WebTitle;
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}
@section css {
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <style>
        th {
            text-align: center;
            font-weight: bold;
        }

        td {
            text-align: center;
            vertical-align: middle;
        }
    </style>
}
<div class="page-content" ng-cloak ng-controller="CheckFormController" ng-init="GetDepartmentList();SelectedOption=[];
     Id='@(Request.QueryString["Id"].IsEmpty() ? "" : Request.QueryString["Id"])';
     page='@(Request.QueryString["page"].IsEmpty() ? "1" : Request.QueryString["page"])';
     GetSpecialTask(Id);
     ">
    <div class="load" ng-show="DataLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />
			</path>
		</svg>
            <div class="load-msg">正在加载...</div>
        </div>
    </div>
    <div class="page-heading">
        <h1>编辑专项检查</h1>
        <div class="options">
            <div class="btn-toolbar">

            </div>
        </div>
    </div>
    <ol class="breadcrumb">
        <li><a>主体业务</a></li>
        <li><a>专项检查</a></li>
        <li class="active"><a>编辑专项检查</a></li>
    </ol>

    <div class="container-fluid">
        <div class="row">
            <form class="form-horizontal row-border">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading"><h2>新建专项检查</h2></div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>专项检查名称：</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" placeholder="专项检查名称" ng-model="SpecialTaskModel.TaskName" />
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>检查时间：</label>
                                <div class="col-sm-4">
                                    <datepicker id="startTime" option="datetimeOption" format="L" ng-model="SpecialTaskModel.StartTime"></datepicker>
                                </div>
                                <div class="col-sm-4">
                                    <datepicker id="endTime" option="datetimeOption" format="L" ng-model="SpecialTaskModel.EndTime"></datepicker>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>部门：</label>
                                <div class="col-sm-8">
                                    <label class="radio-inline">
                                        <input type="checkbox" id="Department_All" name="Department_All" ng-click="SelectAll('Department_All','DepartmentSelected')"> 全选
                                    </label>
                                    <label class="radio-inline" ng-repeat="x in DepartmentList">
                                        <input type="checkbox" id="{{x.Id}}" name="DepartmentSelected"> {{x.DepartmentName}}
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>检查项目：</label>
                                <div class="col-sm-8">
                                    <label class="control-label" style="color:red;" ng-show="SelectedOption.length==0">暂未选择任何检查项目</label>
                                    <ul class="sortable-connected list-unstyled" id="SelectedCheckList">
                                        <li class="card-task card-info" id="{{x.Id}}" ng-repeat="x in SelectedOption">
                                            <div class="card-handle"></div>
                                            <div class="card-title">
                                                <h3>{{x.CheckContent}}</h3>
                                                <div class="card-done">{{$index+1}}/{{SelectedOption.length}}</div>
                                            </div>
                                            <p class="card-desc">
                                                <label class="radio-inline">
                                                    <input type="radio" name="CheckItem_{{x.Id}}" ng-checked="!x.IsValue" id="Result_0_{{x.Id}}">定性
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" name="CheckItem_{{x.Id}}" ng-checked="x.IsValue" id="Result_1_{{x.Id}}">定量
                                                </label>
                                            </p>
                                            <div class="card-options">
                                                <div class="pull-left">
                                                </div>
                                                <div class="pull-right">
                                                    <div class="btn-group">
                                                        <a class="btn btn-default-alt btn-xs" ng-click="RemoveCheckOption(SelectedOption,x);"><i class="fa fa-fw fa-times"></i></a>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="col-sm-1">
                                    <a data-toggle="modal" href="#CheckOptionModal" class="btn btn-primary">选择检查项目</a>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>备注：</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" ng-model="SpecialTaskModel.Remark" />
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label"><b style="color:red;"></b>通知文件：</label>
                                <div class="col-sm-8">
                                    <input type="file" class="form-control" id="taskfile" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">文件列表：</label>
                                <div class="col-sm-8">
                                    <table class="table table-striped table-bordered table-hover">
                                        <thead>
                                            <tr style="background-color:blueviolet;">
                                                <th style="width:5%">序号</th>
                                                <th style="width:30%">文件名称</th>
                                                <th style="width:10%">文件大小(kb)</th>
                                                <th style="width:10%">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr ng-show="SpecialTaskModel.FileList.length==0">
                                                <td colspan="4" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                            </tr>
                                            <tr ng-repeat="x in SpecialTaskModel.FileList">
                                                <td ng-bind="$index+1"></td>
                                                <td ng-bind="x.FileName"></td>
                                                <td ng-bind="x.FileSize"></td>
                                                <td>
                                                    <a href="../Download/DownloadFile?FileId={{x.FileId}}" class="btn btn-success btn-xs btn-label"><i class="fa fa-download"></i>下载</a>
                                                    <a ng-click="DeleteSpecialCheckTaskFile(x.FileId,SpecialTaskModel.FileList);" class="btn btn-danger btn-xs btn-label"><i class="fa fa-trash-o"></i>删除</a>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="panel-footer">
                            <div class="col-md-4">
                            </div>
                            <div class="col-md-1">
                                <button class="btn-primary btn" ng-click="EditCheckTask(SpecialTaskModel,0,page);">保存</button>
                            </div>
                            <div class="col-md-1">
                                <button class="btn-primary btn" ng-click="EditCheckTask(SpecialTaskModel,1,page);">提交</button>
                            </div>
                            <div class="col-md-1">
                                <a href="SpecialCheckTaskPageList?page={{page}}" class="btn-default btn">返回</a>
                            </div>
                            <div class="col-md-3">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal fade" id="CheckOptionModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog" style="min-width:1250px;">
                        <div class="modal-content" style="min-height: 700px;">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h2 class="modal-title">选择检查项目</h2>
                            </div>
                            <div class="modal-body" style="min-height: 660px;">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="panel panel-default">
                                            <div class="panel-heading"><h2>已选检查项</h2></div>
                                            <div class="panel-body" style="height:100%;">
                                                <div class="row">
                                                    <div class="col-sm-9">
                                                        <input type="text" class="form-control" placeholder="检查项模糊搜索" ng-model="CheckOption.CheckCotent" ng-change="GetCheckOptionList(CheckOption.CheckCotent,CheckOptionList);" />
                                                    </div>
                                                    <div class="col-sm-3">
                                                        <button class="btn btn-info" ng-click="AddSpeicalCheckOption(CheckOption.CheckCotent);">没有？添加</button>
                                                    </div>
                                                </div>
                                                <div class="row" style="margin-top:20px;">
                                                    <div class="col-sm-12">
                                                        <div class="alert alert-inverse alert-info" style="padding:10px;" ng-show="CheckOptionList==null || CheckOptionList.length==0">
                                                            无搜索结果...
                                                        </div>
                                                        <div class="alert alert-dismissable alert-info" style="padding:10px;" ng-repeat="x in CheckOptionList">
                                                            {{$index+1}}.{{x.CheckContent}}
                                                            <button type="button" class="close" ng-click="SelectCheckOption(x);">√</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="panel panel-default">
                                            <div class="panel-heading"><h2>已选检查项</h2></div>
                                            <div class="panel-body panel-no-padding">
                                                <table id="example" class="table table-striped" cellspacing="0" width="100%">
                                                    <tbody>
                                                        <tr ng-show="SelectedOption.length==0">
                                                            <td colspan="3">
                                                                暂未选择检查项
                                                            </td>
                                                        </tr>
                                                        <tr ng-repeat="y in SelectedOption">
                                                            <td>{{$index+1}}</td>
                                                            <td style="text-align:left;">{{y.CheckContent}}</td>
                                                            <td><button type="button" ng-click="RemoveCheckOption(SelectedOption,y);">×</button></td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->

                <div class="modal fade" id="PlaceModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog" style="min-width:1250px;">
                        <div class="modal-content" style="min-height: 700px;">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h2 class="modal-title">选择检查场所</h2>
                            </div>
                            <div class="modal-body" style="min-height: 660px;">
                                <div class="form-group">
                                    <label class="col-sm-1 control-label"><b style="color:red;"></b>部门：</label>
                                    <div class="col-sm-8">
                                        <label class="radio-inline" ng-repeat="x in DepartmentList">
                                            <input type="checkbox" name="Department_{{x.Id}}">{{x.DepartmentName}}
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-1 control-label"><b style="color:red;"></b>场所类型：</label>
                                    <div class="col-sm-8">
                                        <label class="radio-inline" ng-repeat="x in PlaceTypeList">
                                            <input type="checkbox" name="PlaceType_{{x.Id}}">{{x.PlaceType}}
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
            </form>
        </div>

    </div>

</div>


@section Js{
    <script src="~/Assets/js/libs/upload.js"></script>
    <script src="~/Assets/js/pg/CheckForm.js?v=@DateTime.Now.ToString("yyMMddHHmm")"></script>
    <script src="~/Assets/js/libs/moment.min.js"></script>
    <script src="~/Assets/js/libs/locales/date/zh-cn.js"></script>
    <script src="~/Assets/js/libs/bootstrap-datetimepicker.min.js"></script>
    <script src="~/Assets/js/libs/angularjs-datepicker.js"></script>
    <script src="~/Assets/js/libs/fileinput.js"></script>
    <script src="~/Assets/js/libs/zh.js"></script>
    <script>
        $('#SelectedCheckList').sortable({
            connectWith: ".sortable-connected",
            receive: function (event, ui) {
                var lists = $('.sortable-connected');
                for (var i = lists.length - 1; i >= 0; i--) {
                    if ($(lists[i]).children().length < 1) $(lists[i]).html('');
                };
            }
        });
    </script>
}
